#ifndef __DBS_GSDBHANDLER_H__
#define __DBS_GSDBHANDLER_H__

#include <string>
#include <hash_map>
#include "sddb.h"
#include "sdhlp/singleton.h"
#include "sdhlp/simpleobjectpool.h"
#include "sdsvrhandler.h"
#include "macros.h"
#include "svr_protheader.h"
//#include "is_protocol.pb.h"

using namespace SGDP;

class CISProto;
class CGSHandler : public ISDSvrHandler
{
    DECLARE_SINGLETON(CGSHandler)
public:
    ///Interface of ISDSvrHandler
    virtual UINT16 GetBusinessID(void) { return SD_ITEM_SERVER; };
    virtual void ProcessPacket(UINT32 dwSvrID, const char * pszBuf, UINT32 dwBufLen);
    virtual void OnConnected(UINT32 dwSvrID);
    virtual void OnDisConnected(UINT32 dwSvrID, INT32 nErrCode);

    bool Run(void);
    bool Send(UINT32 dwSvrID, UINT32 dwTransID, int nMsgID, ::google::protobuf::Message * pMsg);

protected:
    CGSHandler(void);
    virtual ~CGSHandler(void);

    void _OnProcessEnter(UINT32 dwSvrID, UINT32 dwTransID, GIPKG_ENTER_REQ * pEnterReq);
    void _OnProcessLeave(UINT32 dwSvrID, UINT32 dwTransID, GIPKG_LEAVE_REQ * pLeaveReq);
    void _OnProceRoleMsg(UINT32 dwSvrID, UINT32 dwTransID, UINT16 wMsgID, ::google::protobuf::Message * pMsg);
private:
    CISProto m_oProto;
};

#endif

